package com.example.myproject.redis.redisother.fangan2;

import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

/**
 * Created by xi on 2019/3/2.
 */
//@Component
public class RedisSubListenerConfig2 {
    //初始化监听器
    @Bean RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        container.addMessageListener(new ReceiverListener(), new PatternTopic("mytopic"));
        return container;
    }
}
